package com.byt.framlib.commonwidget;

import android.content.Context;
import androidx.annotation.ColorInt;
import androidx.annotation.DrawableRes;
import androidx.annotation.Nullable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.byt.framlib.R;

public class TextAmanLabel extends LinearLayout {

    private Context mContext;
    private View view;

    private View v_layout_label_left;
    private View v_layout_label_right;
    private TextView tv_layout_aman_label;

    public TextAmanLabel(Context context) {
        this(context, null);
        this.mContext = context;
    }

    public TextAmanLabel(Context context, @Nullable AttributeSet attrs) {
        this(context, attrs, 0);
        this.mContext = context;
    }

    public TextAmanLabel(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        this.mContext = context;
        initView(context);
    }

    private void initView(Context mContext) {
        view = LayoutInflater.from(mContext).inflate(R.layout.layout_user_aman_label, this, true);
        v_layout_label_left = view.findViewById(R.id.v_layout_label_left);
        v_layout_label_right = view.findViewById(R.id.v_layout_label_right);
        tv_layout_aman_label = view.findViewById(R.id.tv_layout_aman_label);
    }

    public void setLayoutAmanLabel(String lable) {
        if (tv_layout_aman_label != null) {
            tv_layout_aman_label.setText(lable);
        }
    }

    public void setLayoutAmanLabelBgColor(@ColorInt int color) {
        if (tv_layout_aman_label != null) {
            tv_layout_aman_label.setBackgroundColor(color);
        }
    }

    public void setLayoutAmanLabelBgDrawable(@DrawableRes int resId) {
        if (tv_layout_aman_label != null) {
            tv_layout_aman_label.setBackgroundResource(resId);
        }
    }

    public TextView getLayoutAmanLabelView() {
        return tv_layout_aman_label;
    }

    public void setViewLeft(int visibility) {
        if (v_layout_label_left != null) {
            v_layout_label_left.setVisibility(visibility);
        }
    }

    public void setViewRight(int visibility) {
        if (v_layout_label_right != null) {
            v_layout_label_right.setVisibility(visibility);
        }
    }

    public void setViewLeftBg(@DrawableRes int resid) {
        if (v_layout_label_left != null) {
            v_layout_label_left.setBackgroundResource(resid);
        }
    }

    public void setViewRightBg(@DrawableRes int resid) {
        if (v_layout_label_right != null) {
            v_layout_label_right.setBackgroundResource(resid);
        }
    }
}